package main

import (
	"fmt"
	"gitee.com/sunliang711/locker-control/server/types"
	"github.com/spf13/pflag"
	"log"
)

func main() {
	lockerServerPort := pflag.IntP("lockerServerPort", "l", 7000, "specify locker server port")
	APIPort := pflag.IntP("apiPort", "a", 7500, "specify api server port")
	protocol := pflag.IntP("protocolVersion", "p", 2, "specify protocol version:2 or 4")
	checkInterval := pflag.IntP("checkLivenessInterval", "", 60, "check liveness interval,default:60")
	livenessTimeout := pflag.IntP("livenessTimeout", "", 60, "liveness timeout,default:60")
	pflag.Parse()

	srv, err := types.NewServer(
		fmt.Sprintf(":%d", *lockerServerPort),
		fmt.Sprintf(":%d", *APIPort),
		types.Version(*protocol),
		*checkInterval,
		*livenessTimeout,
	)
	if err != nil {
		log.Fatal(err)
	}
	srv.Start()
}
